from fastapi import APIRouter
from APP.config.log_conf import log
from APP.common.respones.response_schema import response_base
from APP.app.userprofile.services.profile_explicit_service import ProfileExplicitService
from APP.app.userprofile.services.profile_implicit_service import ProfileImplicitService
from APP.utils.serializers import select_list_serialize
from APP.app.userprofile.schemas.user_profile_schema import UserTag

profile_explicit_router = APIRouter()


@profile_explicit_router.post('/generate', summary='生成显示人才画像标签', description='根据用户基础信息生成人才画像')
async def generate_profile():

    user_infos = await ProfileExplicitService.get_user_all()
    data = select_list_serialize(user_infos)
    #判断data字典是否为空
    if not data:
        return response_base.fail(data='未提取画像用户信息')
    
    #执行显示标签提取
    usertags = await ProfileExplicitService.extract_explicit_tags(data)
    
    return response_base.success(data=usertags)

@profile_explicit_router.post('/implicit_tags', summary='生成隐式标签', description='根据用户基础信息生成人才画像的隐式标签')
async def generate_implicit_tags():

    user_infos = await ProfileExplicitService.get_user_all()
    data = select_list_serialize(user_infos)

    usertags = await ProfileImplicitService.extract_implicit_tags(data)
    
    return response_base.success(data=usertags)

